﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp3
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("请输入数据：");
            int num = 0;
            while (true)
            {
                try
                {
                    num = Int32.Parse(Console.ReadLine());
                }
                catch
                {
                    Console.WriteLine("请重新输入数据：");
                    continue;
                }
                break;
            }
            int[] result = Program.PrimeNumber(num);
            foreach (int number in result)
            {
                Console.WriteLine(number);
            }
            
        }
        public static int[] PrimeNumber(int num)
        {
            int[] record = new int[num];
            int counter = 0;
            int num1 = num;
            int i = 2;
            while (num1 >= i)
            {
                while (num1 % i == 0)
                {
                    num1 = num1 / i;
                }
                if (num1 != num)
                {
                    num = num1;
                    record[counter] = i;
                    counter++;
                    i++;
                }
                for(int j=0;j<counter;j++)
                {
                    if (counter != 0 && i % record[j] == 0)
                        i++;
                }
            }
            int[] result = new int[counter];
            for (int j = 0; j < counter; j++)
                result[j] = record[j];
            return result;
        }
    }
}
